package com.xpgk.mvc.statistic.trainingStatistic;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.jfinal.plugin.activerecord.Record;
import com.xpgk.constant.ConstantSplitPage;
import com.xpgk.dto.SplitPage;
import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.organization.Organization;
import com.xpgk.mvc.statistic.dailyNursing.DailyNursingStatisticSQL;
import com.xpgk.mvc.statistic.spropagandaTraining.SpropagandaTrainingSQL;
import com.xpgk.mvc.statistic.spropagandaTraining.SpropagandaTrainingXLS;
import com.xpgk.mvc.user.User;
import com.xpgk.tools.ToolDateTime;

public class TrainingStatisticController extends  BaseController{
	
	private  TrainingStatisticService  trainingStatisticService;
	
	public  void  index(){	
		Organization organ=Organization.dao.findById(getCUserOrganIds());
		setAttr("organization", organ);
		setAttr("startTime", ToolDateTime.getMonthOneDay(new Date()));
		render("trainingStatistic.html");
	}
	
	/**获取员工培训列表
	 * 
	 */
	public void  queryTraining()
	{	
		String json = paging(splitPage, TrainingStatisticSQL.sqlId_splitPageSelect, TrainingStatisticSQL.sqlId_splitPageFrom);
		renderJson(json);
	}
	/**导出数据
	 * 
	 */
	public void  excel()
	{	
		SplitPage  splitPage=new SplitPage();
		String  organIds=getPara("organIds");
		String  minTime=getPara("minTime");
		String  maxTime=getPara("maxTime");
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("organIds", organIds);
		param.put("minTime", minTime);
		param.put("maxTime", maxTime);
		splitPage.setPageSize(ConstantSplitPage.default_maxSize);
		splitPage.setQueryParam(param);
		String json = paging(splitPage, TrainingStatisticSQL.sqlId_splitPageSelect, TrainingStatisticSQL.sqlId_splitPageFrom);
		List<Record>  list=(List<Record>)splitPage.getList();
		//搜索条件
		Organization  organ = Organization.dao.findById(organIds);
		String  search="日期："+minTime+"~"+maxTime+",门店："+organ.getStr(Organization.column_name)+",导出人员："+getCUser().getStr(User.column_name); 
		render(new TrainingStatisticXLS(list,search,"员工培训表"));
	}
}
